package greedy;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class minCameraCover {
    int res = 0;
    public int minCameraCover(TreeNode root) {
        if (minCame(root) == 0){
            res++;
        }
        return res;
    }
    public int minCame(TreeNode node){
        if (node == null){
            return 2;
        }
        int left = minCame(node.left);
        int right = minCame(node.right);
        if (left == 2 && right == 2){
            return 0;
        } else if (left == 0 || right == 0){
            res++;
            return 1;
        } else {
            return 2;
        }
    }
}
